<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>评价信息</title>
    <link href="../css/bootstrap.css" rel="stylesheet">
    <link href="../css/font-awesome.css" rel="stylesheet">
    <link href="../css/custom-styles.css" rel="stylesheet">
    <link href="../css/element/index.css" rel="stylesheet">
    <style>
        [v-cloak]{
            display:none;
        }
    </style>
</head>
<body>
<div id="wrapper" v-cloak>
    <div class="row">
        <div class="col-md-12" style="height: 60px;">
            <nav class="navbar navbar-default top-navbar">
                <div class="row">
                    <div class="col-md-2">
                        <a class="navbar-brand" style="width: 100%;background-color: darkslateblue" href="index.html">
                            <strong style="font-size: 20px;">电影订票购票系统</strong>
                        </a >
                    </div>
                    <div class="col-md-10">
                        <div class="navbar-header">
                            <a href="/front/index.html" style="color: white;line-height: 60px;font-size: 16px;margin-left: 30px">
                                <i class="fa fa-desktop"></i>
                            </a >
                        </div>
                        <ul class="nav navbar-top-links navbar-right">
                            <li style="color:white">欢迎您,{{user.name}}</li>
                            <li class="dropdown">
                                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                    <i class="fa fa-user fa-fw"></i>
                                    <i class="fa fa-caret-down"></i>
                                </a >
                                <ul class="dropdown-menu dropdown-user">
                                    <li>
                                        <a href="javascript:void(0)" @click="personalPage">
                                            <i class="fa fa-user fa-fw"></i>个人信息
                                        </a >


                                    </li>
                                    <li class="divider"></li>
                                    <li>
                                        <a href="javascript:void(0)" @click="logout">
                                            <i class="fa fa-sign-out fa-fw"></i>退出
                                        </a >
                                    </li>
                                </ul>
                            </li>
                        </ul>
                    </div>
                </div>
            </nav>
        </div>
    </div>
    <div class="row">
        <div class="col-md-2">
            <nav id="nav-id" class="navbar-default navbar-side">
                <div class="sidebar-collapse">
                    <ul class="nav" id="main-menu">
                        <li>
                            <a href="index.html" > <i class="fa fa-dashboard"></i>首页</a>
                        </li>
                        <li>
                            <a href="#"> <i class="fa fa-sitemap"></i>信息管理<span class="fa arrow"></span></a>
                            <ul class="nav nav-second-level collapse in">
                                <li v-if="authority.indexOf(1) !== -1">
                                    <a href="adminInfo.html" class="active-menu"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">管理员信息</span></a>
                                </li>
                                <li v-if="authority.indexOf(3) !== -1">
                                    <a href="userInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">用户信息</span></a>
                                </li>
                                <li v-if="authority.indexOf(4) != -1">
                                    <a href="messageInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">在线交流信息</span></a>
                                </li>
                                <li v-if="authority.indexOf(1000001) != -1">
                                    <a href="advertiserInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">公告信息</span></a>
                                </li>
                                <li v-if="authority.indexOf(1000003) != -1">
                                    <a href="linkInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">友情链接</span></a>
                                </li>
                                <li v-if="authority.indexOf(1000015) != -1">
                                    <a href="goodsInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">电影详情信息</span></a>
                                </li>
                                <li v-if="authority.indexOf(1000016) != -1">
                                    <a href="cartInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">收藏栏信息</span></a>
                                </li>
                                <li v-if="authority.indexOf(1000017) != -1">
                                    <a href="orderInfo.html"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">订单信息</span></a>
                                </li>
                                <li v-if="authority.indexOf(1000018) != -1">
                                    <a href="commentInfo.html" class="active-menu"> <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">评价信息</span></a>
                                </li>
                                <li v-if="authority.indexOf(1000014) != -1">
                                    <a href="typeInfo.html" > <i class="fa fa-table sub-icon-mg"></i><span class="mini-sub-pro">电影类型信息</span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)" @click="personalPage">
                                        <i class="fa fa-user"></i>个人信息
                                    </a >
                                </li>
                            </ul>
                        </li>
                        <li>
                            <a href="updataPassword.html"> <i class="fa fa-unlock-alt"></i>修改密码</a>
                        </li>
                        <li>
                            <a href="javascript:void(0)" @click="logout"><i class="fa fa-power-off"></i>退出登录</a>
                        </li>
                    </ul>
                </div>
            </nav>
        </div>
        <div class="col-md-10" style="background-color: #e6e6e6">
            <div id="page-wrapper">
                <div class="row">
                    <div class="col-md-12">
                        <h1 class="page-header"><small>评价信息</small></h1>
                    </div>
                </div>
                <div class="row">
                    <div class="panel-default" style="background-color: whitesmoke">
                        <div class="panel-body">
                            <div class="table-responsive">
                                <div class="nx-table-header">
                                    <input type="text" placeholder="请输入搜索内容" v-model="content" @keyup.enter="loadTable(1)">
                                    <i class="glyphicon glyphicon-search"></i>
                                </div>
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>评价内容</th>
                                        <th>评价时间</th>
                                        <th>所属电影</th>
                                        <th>评价用户</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody v-for="item in objs">
                                    <tr>
                                        <td>{{item.id}}</td>
                                        <td>{{item.content}}</td>
                                        <td>{{item.createTime}}</td>
                                        <td>{{item.goodsName}}</td>
                                        <td>{{item.userName}}</td>
                                        <td>
                                            <button class="btn btn-danger btn-xs"@click="del(item)">删除</button>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                                <nav>
                                    <ul class="pagination">
                                        <li class="page-item" v-bind:class="{disabled:preActive}">
                                            <a class="page-link" href="javascript:void(0)" v-on:click="loadTable(pageInfo.pageNum - 1)">上一页</a>
                                        </li>
                                        <li class="page-item" v-bind:class="{disabled:preActive}">
                                            <a class="page-link" href="javascript:void(0)" v-if="pageInfo.pageNum > 1"
                                               v-on:click="loadTable(pageInfo.pageNum - 1)">{{pageInfo.pageNum - 1}}</a>
                                        </li>
                                        <li class="page-item disabled">
                                            <a class="page-link" href="javascript:void(0)" >{{pageInfo.pageNum}}</a>
                                        </li>

                                        <li class="page-item">
                                            <a class="page-link" href="javascript:void(0)" v-if="pageInfo.hasNextPage"
                                               v-on:click="loadTable(pageInfo.hasNextPage?(pageInfo.pageNum + 1):pageInfo.pageNum)">{{pageInfo.pageNum + 1}}</a>
                                        </li>
                                        <li class="page-item" v-bind:class="{disabled:nextActive}">
                                            <a class="page-link" href="javascript:void(0)"
                                               v-on:click="loadTable(pageInfo.hasNextPage?(pageInfo.pageNum + 1):pageInfo.pageNum)">下一页</a>
                                        </li>
                                    </ul>
                                </nav>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../js/jquery-1.10.2.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/jquery.metisMenu.js"></script>
<script src="../js/custom-scripts.js"></script>
<script src="../js/my.js"></script>
<script src="../js/vue2.6.11/vue.min.js"></script>
<script src="../js/vue2.6.11/axios.js"></script>
<script src="../js/echarts.min.js"></script>
<script src="../js/element/index.js"></script>
<script>
    function msg(type,msg) {
        Vue.prototype.$message({
            type: type,      //success(成功),warning(警告),error(错误)
            message: msg,
            duration: 2000,
            offset: 100,
            center: true
        });
    }
    new Vue({
        el: "#wrapper",
        data: {
            user: {},
            authority:[],
            permission: [],
            content: '',  // 根据评价内容模糊查询
            objs: [],   //列表
            pageInfo: {},
            preActive: true,  // 上一页是否可点击
            nextActive: true,  // 下一页是否可点击
        },
        created: function () {
            this.user = JSON.parse(localStorage.getItem('user'));
            axios.get("/permission/1000018").then(res => {
                if (res.data.code === '0') {
                    this.permission = res.data.data;
                } else {
                    msg('error', res.data.msg);
                }
            });

            this.loadTable(1);
        },
        method:{
            //加载评价列表
            loadTable(pageNum){
                // 查询权限
                axios.get('/auth').then(res => {
                    if (res.data.code == '0') {
                        this.user = res.data.data;
                        // 若是管理员
                        if (this.user.level === 1) {
                            // 显示可以进入后台
                            this.isShow = true;
                        }
                        this.isLogin = true;
                        let content=this.content === ''?'all':this.content;
                        // 获取评价列表
                        axios.get("/commentInfo/page/" + content+ "?pageNum=" + pageNum).then((res) => {
                            if (res.data.code === '0') {
                                this.objs = res.data.data.list;
                                this.pageInfo = res.data.data;
                                this.preActive =!(this.pageInfo.hasPreviousPage);
                                this.nextActive =!(this.pageInfo.hasNextPage);
                            } else {
                                msg(res.data.msg);
                            }
                        });
                    }else {
                        msg("请先登录");
                        location.href = '/end/page/login.html';
                    }
                });
            },

            //删除某个评价
            del(data){
                if(confirm('确定删除该评价吗？')){
                    axios.delete('/commentInfo/'+data.id).then(res=>{
                        if(res.data.code === '0'){
                            msg('删除成功');
                            this.loadTable(1);
                        }else{
                            msg(res.data.msg);
                        }
                    });
                }
            },


        }
    });
</script>
</body>
</html>